let arr = [5,8,23,8,345,6,1]

function bubbleSort(arr) {
  for (let index = 0; index < arr.length; index++) {
    for (let i2 = 0; i2 < arr.length; i2++) {
      if (arr[i2] > arr[i2 + 1]) {
        let temp = arr[i2 + 1]
        arr[i2 + 1] = arr[i2]
        arr[i2] = temp
      }
    }
  }

  return arr;
}

console.log(bubbleSort(arr))